package com.epoint.mobileoa.adapter;

import java.util.List;
import java.util.Map;

import com.epoint.mobileoa.bizlogic.Res;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class FileChooseAdp extends BaseAdapter {
	private LayoutInflater mInflater;
	List<Map<String, Object>> mData;

	public FileChooseAdp(Context context, List<Map<String, Object>> mData) {
		this.mInflater = LayoutInflater.from(context);
		this.mData = mData;
	}

	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(Res.getLayoutInt("listviewfile"), null);
			holder.fc_img = (ImageView) convertView.findViewById(Res.getIdInt("fc_img"));
			holder.fc_title = (TextView) convertView
					.findViewById(Res.getIdInt("fc_title"));
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.fc_img.setBackgroundResource((Integer) mData.get(position).get(
				"icon"));
		holder.fc_title.setText((String) mData.get(position).get("name"));
		return convertView;
	}

	class ViewHolder {
		public ImageView fc_img;
		public TextView fc_title;
	}
}
